package es.xpt.ysf.jaas;

import javax.servlet.http.HttpSessionEvent;

import es.xpt.ysf.configuration.Configuration;
import es.xpt.ysf.configuration.ConfigurationParameterNames;
import es.xpt.ysf.view.model.UserBean;
import es.xpt.ysf.web.Constants;

public class WebLoginSessionListener { // NO_UCD 

	public void sessionCreated(HttpSessionEvent e, UserBean ub) {

		String environment = e.getSession().getServletContext().getInitParameter("es.xpt.ysf.view.model.UserBean.environment");
		String application = e.getSession().getServletContext().getInitParameter("es.xpt.ysf.view.model.UserBean.application");
		ub.setEnvironment(environment);
		if (application != null) {
			ub.setApplication(application);
			Configuration c = new Configuration(ub.getApplication());
			ub.setDatasource(c.getString(ConfigurationParameterNames.DATASOURCE));
			ub.setBigData(c.getString(ConfigurationParameterNames.BIG_DATA));
		}
		
		e.getSession().setAttribute(Constants.USER_INFORMATION.getValue(), ub);		
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {

	}

}